package com.chendechao.model_home.ui.recommend.comment


import com.chendechao.lib_base.BaseRepository
import com.chendechao.model_home.ui.HomApiService
import okhttp3.RequestBody

import javax.inject.Inject


class CommentRepository @Inject constructor(): BaseRepository(){
    @Inject
    lateinit var apiService: HomApiService

    //评论
    suspend fun getCommentListData(): Result<CommentUIState>{
        val res = apiService.getCommentListData(0,"1")
        return if (res.code == 200) {
            Result.success(CommentUIState(comentData = res.data, isSucess = true))
        } else {
            Result.failure(IllegalArgumentException("没有数据"))
        }
    }

    suspend fun postSendCommentData(body: RequestBody): Result<SendCommentUIState>{
        val res = apiService.postSendCommentData(body)
        return if (res.agreenum == 200) {
            Result.success(SendCommentUIState(SendcomentData = res.replyList, isSucess = true))
        } else {
            Result.failure(IllegalArgumentException("没有数据"))
        }
    }



}